package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.PmsProductTag;
import com.macro.mall.model.PmsProductTagVo;
import com.macro.mall.service.PmsProductTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/PmsProductTag")
public class PmsProductTagController {
    @Autowired
    private PmsProductTagService pmsProductTagService;

    /**
     * 根据ID查询
     * @param tagId
     * @return
     */
    @PostMapping("/findById/{tagId}")
    public CommonResult findById(@PathVariable String tagId){
        PmsProductTag pmsProductTag = pmsProductTagService.findById(tagId);
        return CommonResult.success(pmsProductTag);
    }

    /**
     * 列表查询
     * @param pmsProductTagVo
     * @return
     */
    @PostMapping("/list")
    public CommonResult<List<PmsProductTag>> list(@RequestBody PmsProductTagVo pmsProductTagVo){
        return CommonResult.success(pmsProductTagService.list(pmsProductTagVo).getList());
    }

    /**
     * 添加
     * @param pmsProductTag
     * @return
     */
    @PostMapping("/save")
    public CommonResult save(@RequestBody PmsProductTag pmsProductTag){
        pmsProductTagService.save(pmsProductTag);
        return CommonResult.success(null,"添加成功");
    }

    /**
     * 修改
     * @param pmsProductTag
     * @return
     */
    @PutMapping("/update")
    public CommonResult update(@RequestBody PmsProductTag pmsProductTag){
        pmsProductTagService.update(pmsProductTag);
        return CommonResult.success(null,"修改成功");
    }

    /**
     * 单删
     * @param id
     * @return
     */
    @DeleteMapping("/remove/{id}")
    public CommonResult remove(@PathVariable String id) {
        pmsProductTagService.remove(id);
        return CommonResult.success(null,"删除成功");
    }


}



